package com.zl.cms.model;


import org.hibernate.validator.constraints.NotEmpty;

/**
 * User: zl email:c3tc3tc3t@126.com Date: 14-2-1 Time: 下午2:26
 */
// @Entity
// @Taable(name="t_channel")
public class Channel {
  public static final String ROOT_NAME = "网站系统栏目";
  public static final int ROOT_ID = 0;
  /**
   * 栏目主键
   */
  private int id;
  /**
   * 栏目名称
   */
  private String name;
  /**
   * 栏目是否是自定义链接, 0表示否，1表示是
   */
  private int customLink;
  /**
   * 自定义链接的地址
   */
  private String customLinkUrl;
  /**
   * 栏目的类型，枚举类型，该枚举中有name属性来标识栏目中文名称
   */
  private ChannelType type;
  /**
   * 是否是首页栏目,0表示否，1表示是
   */
  private int index;
  /**
   * 是否是首页顶部导航栏目,0表示否，1表示是
   */
  private int topNav;
  /**
   * 是否是推荐了栏目,0表示否，1表示是
   */
  private int recommed;
  /**
   * 表示栏目的状态 ，0表示启用，1表示不启用
   */
  private int status;
  /**
   * 栏目的序号
   */
  private int orders;

  /**
   * 父栏目
   */
  private Channel parent;

  // @ManyToOne
  // @JoinColumn(name="pid")
  public Channel getParent() {
    return parent;
  }

  public void setParent(Channel parent) {
    this.parent = parent;
  }

  public Channel() {}

  public Channel(int id, String name) {
    this.id = id;
    this.name = name;
  }


  // @Id
  // @GeneratedValue(strategy = GenerationType.IDENTITY)
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }
@NotEmpty(message="栏目不能为空")
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  // @Colunm(name="custom_link")
  public int getCustomLink() {
    return customLink;
  }

  public void setCustomLink(int customLink) {
    this.customLink = customLink;
  }

  // @Colunm(name="custom_link_url")
  public String getCustomLinkUrl() {
    return customLinkUrl;
  }

  public void setCustomLinkUrl(String customLinkUrl) {
    this.customLinkUrl = customLinkUrl;
  }

  public ChannelType getType() {
    return type;
  }

  public void setType(ChannelType type) {
    this.type = type;
  }

  // @Colunm(name="is_index")
  public int getIndex() {
    return index;
  }

  public void setIndex(int index) {
    this.index = index;
  }

  // @Colunm(name="is_top")
  public int getTopNav() {
    return topNav;
  }

  public void setTopNav(int topNav) {
    this.topNav = topNav;
  }

  public int getRecommed() {
    return recommed;
  }

  public void setRecommed(int recommed) {
    this.recommed = recommed;
  }

  public int getStatus() {
    return status;
  }

  public void setStatus(int status) {
    this.status = status;
  }

  public int getOrders() {
    return orders;
  }

  public void setOrders(int orders) {
    this.orders = orders;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Channel channel = (Channel) o;

    if (id != channel.getId()) return false;
    if (!name.equals(channel.getName())) return false;
    if (type != channel.getType()) return false;

    return true;
  }

  @Override
  public int hashCode() {
    int result = id;
    result = 31 * result + name.hashCode();
    result = 31 * result + (type != null ? type.hashCode() : 0);
    return result;
  }

  @Override
  public String toString() {
    return "Channel{" + "id=" + id + ", name='" + name + '\'' + ", customLink=" + customLink
        + ", customLinkUrl='" + customLinkUrl + '\'' + ", type=" + type + ", isIndex=" + index
        + ", isTopNav=" + topNav + ", recommed=" + recommed + ", status=" + status + ", orders="
        + orders + '}';
  }
}
